import helpInfoApi from "../../../api/helpInfo";
Page({
  data: {
    statusBarHeight: getApp().globalData.statusBarHeight,
    tabList: [
      {
        name: '常见问题',
        icon: '/static/icons/icon08.png',
        type: 1
      },
      {
        name: '设备资料',
        icon: '/static/icons/icon09.png',
        type: 2
      },
      {
        name: '操作手册',
        icon: '/static/icons/icon10.png',
        type: 3
      },
    ],
    cur: 0,
    pageSize: 10,
    pageNum: 1,
    status: 'more',
    list: [],
    type: 1
  },
  onLoad: function (options) {
    this.init()
  },
  init () {
    let params = {
      pageSize: this.data.pageSize,
      pageNum: this.data.pageNum,
      type: this.data.type
    }
    helpInfoApi.getHelpInfoList(params).then(res => {
      this.data.list = this.data.list.concat(res.rows)
      this.data.pageNum++
      this.setData({
        list: this.data.list,
        pageNum: this.data.pageNum
      })
      if(res.rows.length < this.data.pageSize){
        this.setData({
          status: 'noMore',
        })
      }
    })
  },
  changeTab (e) {
    let { index, type } = e.currentTarget.dataset;
    this.setData({
      cur: index,
      type: type,
      pageNum: 1,
      list: []
    })
    this.init();
  },
  jump (e) {
    let { id, title } = e.currentTarget.dataset;
    wx.navigateTo({
      url: `/pages/mine/problemDetail/index?id=${id}&title=${title}`
    })
  }
});